﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MaxLeaf.Platform.Contract;
using MaxLeaf.Platform.BLLImplementation;
using CommonsLib.Utility;
using MaxLeaf.Platform.DataContract;
using CommonsLib.Settings;
using MaxLeaf.Platform.Functions;

namespace MaxLeaf.Platform.BLLProxy
{

    /// <summary>
    /// 用户操作
    /// </summary>
    public class mUser_MainBLLProxy : BaseBLLProxy, IUser
    {

        IUser _bll;
        private  IUser BLL
        {
            get
            {                
                return _bll;
            }
        }
        public mUser_MainBLLProxy():base()
        {
            switch ( Access_Mode )
            {

                case MaxLeaf.Platform.Commons.Const.ACCESS_Direct:
                    {
                        _bll = new mUser_MainBLL();
                        break;
                    }

                case MaxLeaf.Platform.Commons.Const.ACCESS_IIS:
                    {
                        _bll = new mUser_MainBLLWCFClient(this.WCF_Configs);
                        break;
                    }


                default:
                    {
                        throw new MaxLeaf.Platform.Commons.MaxLeafException(MaxLeaf.Platform.Commons.Const.EXCEPTION_MESSAGE_INVALID_ACCESSMODE_CONFIG);

                    }
            }
        }
         

        #region IUser 成员

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="strUserName">用户名</param>
        /// <param name="strPassword">密码</param>
        /// <returns>用户信息</returns>
        public mUser_MainDataModel Login(string strUserName, string strPassword)
        {
            return BLL.Login(strUserName, strPassword);
        }

        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="strUserName">用户名</param>
        /// <param name="strOldPassword">旧密码</param>
        /// <param name="strNewPassword">新密码</param>
        /// <returns>是否成功</returns>
        public bool ResetPassword(string strUserName, string strOldPassword, string strNewPassword)
        {
            LogManager.Debug(string.Format("User {0} ResetPassword ",strUserName));
            return BLL.ResetPassword(strUserName, strOldPassword,strNewPassword);
        }

        #endregion
    }
}
